package pl.mdziedzic.unittests;

import java.util.Calendar;

import pl.mdziedzic.unittests.services.RequestContext;

public class AuctionBuilder {
	
	static final String AUCTION_NAME = "Example auction";
	static final int BUY_NOW_PRICE = 1000;

	public User user;
	public RequestContext context;
	public Calendar startTime;
	public Calendar endTime;
	
	public static AuctionBuilder anAuction() {
		return new AuctionBuilder();
	}
	
	private AuctionBuilder() {
		user = new User("example.user");
		context = new RequestContext(user);

		startTime = Calendar.getInstance();
		startTime.add(Calendar.DATE, 1);

		endTime = (Calendar) startTime.clone();
		endTime.add(Calendar.DATE, 7);
	}
	
	public AuctionBuilder withUser(User user) {
		this.user = user;
		return this;
	}
	
	public AuctionBuilder withStartTime(Calendar startTime) {
		this.startTime = startTime;
		return this;
	}
	
	public Auction build(){
		
		CreateAuctionRequest request = CreateAuctionRequest
				.createBuyNowAuction(AUCTION_NAME, startTime, endTime,
						BUY_NOW_PRICE);
		
		return new Auction(context, request);
	}

}
